<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<style>
#view table, #bar table {
	margin:10px auto;
	box-shadow: 0px 0px 50px #a7a8ad;
	    
}
#view table, #bar table{border-collapse:collapse;width:80%;margin:10px auto;}
#view table th,#bar table th{background:#F2F7FE;padding:3px;border:1px solid #B8CCE2;padding-left:5px;color:#333;height:24px;text-align:center;}
#view table td,#bar table td{padding:2px;border:1px solid #B8CCE2;color:#333;height:24px;text-align:center;}
</style>
<script type="text/javascript">
	$(function() {
		var params = {} ;
		$.post($.webapp.root+"/admin/system/org/combo_sync_tree_excutorself.do?pid=${USER_SESSION.user.org_id}", function(result) {
			$("#org_search").combotree({
				editable: false, lines:true,
				onSelect: function(record) {
					params["deptName"] = record.name ;
					params["deptid"] = record.id ;
					loadListInfo(params) ;
	            }
		    });
			$("#org_search").combotree("loadData", result) ;
			
			params["deptName"] = result[0].name ;
			params["deptid"] = result[0].id ;
			$("#org_search").combotree("setValue", result[0].id) ;
		});
		
		function loadListInfo(params) {
			var infoContainet = $("#deptinfo_box").empty();
			$.post($.webapp.root + "/admin/system/deptinfo_category/getCategoryByDept.do", params, function(result) {
				
				if(result.length > 0) {
					$.each(result, function(i, item) { 
						var d1 = $("<div></div>").addClass("deptinfo_container").appendTo(infoContainet) ;
						var h3 = $("<h3></h3>").addClass("title").appendTo(d1) ;
						var h3_sp0 = $("<span></span>").attr("id", "title").html(item.name).appendTo(h3) ;
						var h3_sp1 = $("<span></span>").attr("id", "more").html("更多").appendTo(h3) ;
						//var h3_sp2 = $("<span></span>").attr("id", "ref_icon").appendTo(h3) ;
						var list_box = $("<div></div>").addClass("list1").appendTo(d1) ;
						var ul = $("<ul></ul>").appendTo(list_box) ;
						
						h3_sp1.click(function() {
							window.mainpage.addModuleTab({
								title: $(this).siblings("#title").text(),
								iniframe: true,
								href: $.webapp.root + "/admin/system/deptinfo_item/deptinfo_view_by_category_root_UI.do?id="+item.id
							});
							
						});
						
						$.post($.webapp.root + "/admin/system/deptinfo_item/view_datagrid.do", {"categoryId" : item.id, rows: 5,sort: "created", order: "desc"}, function(list) {
							$.each(list.rows, function(i, item) {
								var li = $("<li></li>").appendTo(ul);
								li.html('<div><span>'+item.createName+'</span><a href="'+$.webapp.root+'/admin/system/deptinfo_item/deptinfo_open_UI.do?id='+item.id+'" target="_blank">'+item.subject+'</a></div>') ;
							});
						});
					});
				} else {
					infoContainet.html('<div style="width: 80%;margin:0 auto;text-align: center;">没有数据，请通知下属部门上传相关信息。</div>') ;
				}

			}, 'json');
		}
		
		
	});
	
</script>

<div id="bar">
<table>
	<tr>
		<td>
			部门：<input id="org_search" name="org_id" style="width:220px;height:25px;" />
		</tr>
	</table>
</div>

<div id="deptinfo_box">
	
</div>